package com.friend.common.model;


import com.friend.common.constants.ResultConstants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;


/**
 * 接口返回结构
 * @author Lomis
 *
 */
@Data
@ApiModel(value="统一返回对象", description="系统统一返回对象")
public class Result<T> implements Serializable {

	private static final long serialVersionUID = 1L;

	@ApiModelProperty(value = "返回状态码  0、成功 1、失败")
	private String resultCode = ResultConstants.RESULT_CODE_SUCCESS;	// 结果编码 0:成功 1:失败
	@ApiModelProperty(value = "返回消息内容")
	private String resultDesc = ResultConstants.RESULT_DESC_SUCCESS;	// 返回的结果描述
	@ApiModelProperty(value = "返回页面数据")
	private T resultData;	// 返回的结果数据

	public  static <T> Result<T> getDefaultFailureResult(T resultData){
		Result<T> result=new Result<>();
		result.setResultCode(ResultConstants.RESULT_CODE_FAILED);
		result.setResultDesc("未知原因，处理失败");
		result.setResultData(resultData);
		return result;
	}
}
